package com.sc.servlet.admin.field;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mysql.cj.xdevapi.JsonString;
import com.sc.pojo.Field;
import com.sc.services.FieldServices;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @description: 获取要更新的场地信息
 * @author: sc
 * @create: 2023-01-03 17:20
 **/
@WebServlet("/getUpdateField")
public class getUpdateFieldServlet extends HttpServlet {

    private FieldServices fieldServices = new FieldServices();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String fieldid = request.getParameter("fieldid");
        Field field = fieldServices.selectFieldById(Integer.parseInt(fieldid));
        String jsonString = JSON.toJSONString(field);

        // 写数据
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(jsonString);


    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}